#!usr/bin/env python  
# -*- coding:utf-8 -*-
""" 
@author:robot
@file: title4-2.py 
@version:
@time: 2023/05/26 
"""


def solve(n, grids):
    x = [None] * n
    MAP = {}
    for i in range(len(grids)):
        step = grids[i]
        if step[0] not in MAP:
            MAP[step[0]] = []
        MAP[step[0]].append(step[1])
        x[step[1]] = step[0]
    stack = []
    for i in range(n):
        if x[i] is None:
            stack.append(i)

    if not stack:
        return False

    while stack:
        i = stack.pop()
        x[i] = -1
        if i not in MAP:
            continue
        for item in MAP[i]:
            if x[item] != -1:
                stack.append(item)
    return all(val == -1 for val in x)


def main():
    n = int(input())
    grids = []
    while True:
        _input = input()
        if _input:
            grids.append(list(map(int, _input.split())))
        else:
            break
    res = solve(n, grids)
    print('yes' if res else 'no')


main()
